package com.wkr.msg;

import com.wkr.bean.StringBean;
import com.wkr.container.MqContainer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import javax.jms.TextMessage;

/**
 * 消息转换器类
 */
public class WkrMsgConverter implements MessageConverter {

    private static final Logger log = LoggerFactory.getLogger(WkrMsgConverter.class);

    @Override
    public Message toMessage(Object o, Session session) throws JMSException, MessageConversionException {
        return null;
    }

    @Override
    public Object fromMessage(Message message) throws JMSException, MessageConversionException {
        log.info("消息转换开始");
        TextMessage textMessage = (TextMessage) message;
        log.info("消息内容:" + textMessage.getText());
        String temp = textMessage.getText();
        log.info("消息转换结束");
        return new StringBean(temp);
    }

    /**
     * 后面搞清楚这两个的区别
     */
}
